<template>
	<div>
        <TopFilter
        :list="formList"
        :cols="3"
        @filterChange="filterChangeHandle"
        @onCollapse="collapseHandle"
        ></TopFilter>
        <FilterTable
        ref="table"
        :columns="columns"
        :fetchapi="fetchApi"
        :params="fetchParams"
        selectionType="single"
        :datakey="'records'"
        :onRowSelectChange="onRowSelectChange"
        :onColumnsChange="columns => this.columns = columns"
        >
        <!-- <template slot="controls">
            <el-button size="small" type="primary" icon="el-icon-plus" @click="addHandle()">新增</el-button>
        </template> -->
        </FilterTable>
        <div :style="{position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'}"
        >
            <el-button size="small" type="primary"  @click="saveHandle()">保存</el-button>
            <el-button size="small" type="primary"  @click="closeHandler()">关闭</el-button>
        </div>
    </div>    
</template>

<script>
import { queryFinishSalesOrder } from '@/api/retail/salesmanage/vehicleReturn';
import { dictionary } from '@/utils/dictMixin';
import moment from 'moment';
import { systemCode } from '@/utils/validate'
import vRModal from './vRModal'
export default {
	name: 'vehicleReturn',
	mixins: [dictionary],
	components: {
	  vRModal
	},
	data() {
        return {
            formList: this.createFormList(),
            columns: this.createTableColumns(),
            fetchApi: queryFinishSalesOrder,
            fetchParams: {},
            customerNoArr:"",
            row:[],
        }
    },
	methods: {
        createFormList() {
	      return [
	        {
	          type: 'INPUT',
	          label: '销售订单号',
	          fieldName: 'viNo',
              placeholder: '请输入...',
              rules: [{ required: false, validator: systemCode, trigger: 'blur' }]
	        },
            {
	          type: 'INPUT',
	          label: '客户名称',
	          fieldName: 'customerName',
	          placeholder: '请输入...',
	        },
	      ];
	    },
      createTableColumns (){
        return [
          /* {
            title: '操作',
            dataIndex: 'column-action',
            width: 140,
            fixed: 'left',
            render: (props, h) => {
              return (
                <div>
                <el-button  size="mini" type="text" onClick={() => this.editHandle(props.row)}>编辑</el-button>
                <el-button  size="mini" type="text" onClick={() => this.deleteHandle(props.row)}>删除</el-button>
                <el-button  size="mini" type="text" onClick={() => this.subHandle(props.row)}>提交</el-button>
                </div>
              );
            }
          }, */
          {
            title: '序号',
            dataIndex: 'index',
            width: 80,
            sorter: true,
            render: props => {
              return <span>{props.row.index + 1}</span>;
            }
          },
          {
            title: '销售订单号',
            dataIndex: 'viNo',
            sorter: true,
            filter: true,
            filterType: 'input',
          },
          {
            title: 'VIN',
            dataIndex: 'salesVin',
            sorter: true,
            filter: true,
            filterType: 'input',
          },
          {
            title: '客户名称',
            dataIndex: 'customerName',
            sorter: true,
            filter: true,
            filterType: 'input',
          },
          {
            title: '客户编号',
            dataIndex: 'customerNo',
            sorter: true,
            filter: true,
            filterType: 'input',
            /* filterItems: this.createDictList('1404'),
            render: props => {
              return <span>{this.createDictText(props.row.viStatus, '1404')}</span>;
            } */
          },
          {
            title: '品牌',
            dataIndex: 'brandName',
            sorter: true,
            filter: true,
            filterType: 'input',
          },
          {
            title: '车系',
            dataIndex: 'seriesName',
            sorter: true,
            filter: true,
            filterType: 'input',
          },
          {
            title: '车型',
            dataIndex: 'modelName',
            sorter: true,
            filter: true,
            filterType: 'input',
          },
        ]
      },
      
        filterChangeHandle (val){ //搜索
            this.fetchParams = Object.assign({}, val)
        },
        collapseHandle() {
            this.$nextTick(() => {
                this.BaseTable.EXECUTE_RESET_HEIGHT();
            });
        },
        onRowSelectChange(row){
          console.log(row,"row")
          if(row && row.length == 1){
            this.row =row
            row.forEach(x=>{
              this.customerNoArr=x.customerNo
            })
          }
          
        },
        saveHandle(){
            this.$emit('addDialogHandle',this.customerNoArr,this.row)
        },
        closeHandler(){
            this.$emit('close')
        },
	}
}
</script>

<style scoped="scoped" lang="less">

</style>
